#include <xp/bas/stdlib.h>
#include <xp/bas/stdio.h>

int comp (const void* a, const void* b, void* arg)
{
	long long a2 = *(long long*)a;
	long long b2 = *(long long*)b;

	return (a2 > b2)? 1: ((a2 < b2)? -1: 0);
}

int xp_main ()
{
	long long a[] = { 3, 4, 10, 10, 30, 193, 10};
	xp_size_t i;

	xp_printf (XP_TEXT("data count: %u\n"), xp_countof(a));
	
	for (i = 0; i < xp_countof(a); i++) xp_printf (XP_TEXT("%lld "), a[i]);
	xp_printf (XP_TEXT("\n------------\n"));

	xp_qsort (a, xp_countof(a), xp_sizeof(a[0]), XP_NULL, comp);

	for (i = 0; i < xp_countof(a); i++) xp_printf (XP_TEXT("%lld "), a[i]);
	xp_printf (XP_TEXT("\n"));

	return 0;
}
